# -----------------------------
# 配置区
# -----------------------------
$desktop_folder = [Environment]::GetFolderPath("Desktop")  # 自动获取当前用户桌面
$zip_name = "app.zip"

# -----------------------------
# 获取当前目录
# -----------------------------
$current_dir = Get-Location

# -----------------------------
# 手动列出要压缩的文件/文件夹
# -----------------------------
$items_to_zip = @(
    "src",          # 文件夹
    "pom.xml",      # 文件
    "bbb.sh"     # 可以随意增加
)

# 过滤掉不存在的路径
$items_to_zip = $items_to_zip | ForEach-Object {
    $path = Join-Path $current_dir $_
    if (Test-Path $path) {
        $path
    } else {
        Write-Host "警告: $_ 不存在!"
        $null
    }
} | Where-Object { $_ -ne $null }

# -----------------------------
# 压缩
# -----------------------------
$zip_path = Join-Path $current_dir $zip_name

# 如果已有 zip 文件，先删除
if (Test-Path $zip_path) {
    Remove-Item $zip_path -Force
}

Compress-Archive -Path $items_to_zip -DestinationPath $zip_path
Write-Host "已生成压缩包: $zip_path"

# -----------------------------
# 移动到桌面文件夹
# -----------------------------
if (-not (Test-Path $desktop_folder)) {
    New-Item -ItemType Directory -Path $desktop_folder | Out-Null
}

Move-Item -Path $zip_path -Destination $desktop_folder -Force
Write-Host "已移动 $zip_name 到 $desktop_folder"
